﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp8
{//1、猫、狗、鸭、猴，（吃、游泳、爬树）
    class Program
    {
        static void Main(string[] args)
        {
            Cat cat = new Cat("小猫咪");
            A(cat);
            C(cat);
            Console.WriteLine("--------");
            Dog dog = new Dog("小狗");
            A(dog);
            S(dog);
            Console.WriteLine("--------");
            Duck duck = new Duck("小鸭子");
            A(duck);
            S(duck);
            Console.WriteLine("--------");
            Monkey monkey = new Monkey("小猴子");
            A(monkey);
            C(monkey);
            
            Console.ReadKey();
        }
        public static void A(Animal A) 
        {
            A.Eat();
        }
        public static void S(ISwim S)
        {
            S.Swim();
        }
        public static void C(ICt C)
        {
            C.Ct();
        }
    }
    class Cat : Animal,ICt
    {
        public string Name { get; set; }
        public Cat(string name)
        {
            this.Name = name;
        }
        public override void Eat()
        {
            Console.WriteLine(this.Name+"喜欢吃鱼。");
        }

        public void Ct()
        {
            Console.WriteLine(this.Name+"喜欢爬树抓蝴蝶。");
        }
    }
    class Dog : Animal, ISwim
    {
        public string Name { get; set; }
        public Dog(string name)
        {
            this.Name = name;
        }
        public override void Eat()
        {
            Console.WriteLine(this.Name + "喜欢吃大骨头。");
        }

        public void Swim()
        {
            Console.WriteLine(this.Name + "喜欢下水玩耍。");
        }
    }
    class Duck : Animal, ISwim
    {
        public string Name { get; set; }
        public Duck(string name)
        {
            this.Name = name;
        }
        public override void Eat()
        {
            Console.WriteLine(this.Name + "喜欢吃饲料。");
        }

        public void Swim()
        {
            Console.WriteLine(this.Name + "喜欢游泳洗澡。");
        }
    }
    class Monkey : Animal, ICt
    {
        public string Name { get; set; }
        public Monkey(string name)
        {
            this.Name = name;
        }
        public override void Eat()
        {
            Console.WriteLine(this.Name + "喜欢吃桃子。");
        }

        public void Ct()
        {
            Console.WriteLine(this.Name + "喜欢爬树荡秋千。");
        }
    }
    abstract class Animal 
    {
        public abstract void Eat();
    }
    interface ISwim 
    {
        void Swim();
    }
    interface ICt 
    {
        void Ct();
    }
}
